<!DOCTYPE html>
<html>
<head>
    <#assign f = JspTaglibs["http://www.casic304.cn/f"] />
    <meta charset="utf-8">
    <title>质量综合分析报告 信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
    <table id="wQbdQualityAnalysisReportTable" lay-filter="wQbdQualityAnalysisReportTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdQualityAnalysisReportHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
        <@f.a alias="QARxzanGroup" css="layui-btn layui-btn-sm fillBtn" event="add">
            <span>新增</span>
        </@f.a>
        <@f.a alias="QARscanGroup" css="layui-btn layui-btn-sm" event="delete">
            <span>删除</span>
        </@f.a>
        <@f.a alias="QARxfan" event="send" css="layui-btn layui-btn-sm">
            <span>下发</span>
        </@f.a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdQualityAnalysisReportQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">报告名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_name_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">年度</label>
                        <div class="layui-input-block">
                            <input type="text" id="start_time1" class="layui-input  filter-value" name="Q_year_S" placeholder="请输入"/>
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">录入开始时间</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input start_time2 filter-value" name="Q_beginFilldate_DL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">录入结束时间</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input end_time2 filter-value" name="Q_endFilldate_DL" placeholder="请输入" />
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">全文检索</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_content_S" placeholder="请输入"/>
                        </div>
                    </div>

                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdQualityAnalysisReportRightToolsBar">
    {{# if('${currentUserId}'==d.createBy && (d.status==1 || d.status==3)){}}
    <@f.a alias="QARxganGroup" css="RightBtn" event="edit">编辑</@f.a>
    {{#  } }}
    <a class="RightBtn" lay-event="particulars">详情</a>
    {{# if('${currentUserId}'==d.createBy && (d.status==1)){}}
    <@f.a alias="QARscanGroup" css="RightBtn" event="del">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'qbdmsForm', 'common','laydate','publicMethods','jquery','layer','propsHandle'], function () {
        var table = layui.table;
        var form = layui.qbdmsForm;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdQualityAnalysisReportTable');

        var tableH=publicMethods.tabHeight();

        var showSta={field: 'staStr', title: '状态',sort:false, sortname: 'status',hide:true,minWidth: '140',templet: function(d){
                if (d.staStr == null || d.staStr == ''){
                    return "-";
                }else {
                    d.status=d.staStr;
                    return common.issueStateType(d);
                }
            }};
        if('${currentSystemLevel}'=='GROUPLEVEL'){
            showSta={field: 'staStr', title: '状态',sort:false, sortname: 'status',minWidth: '140',templet: function(d){
                    if (d.staStr == null || d.staStr == ''){
                        return "-";
                    }else {
                        d.status=d.staStr;
                        return common.issueStateType(d);
                    }
                }};
        }
        //第一个实例
        table.render({
            elem: '#wQbdQualityAnalysisReportTable'
            ,height:tableH
            ,url: serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/list'
            ,page: publicMethods.pageFun()//开启分页
            ,limit: 20
            ,defaultToolbar: ['']
            ,toolbar: '#wQbdQualityAnalysisReportHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                ,{field: 'year', title: '年度',sort:false, sortname: 'year',minWidth: '80'}
                ,{field: 'name', title: '报告名称',sort:false, sortname: 'name',minWidth: '140'}
                ,{field: 'secretStr', title: '密级',sort:false, sortname: 'secret',minWidth: '80'}
                ,{field: 'fillman', title: '操作人',sort:false, sortname: 'fillman',minWidth: '150'}
                ,{field: 'filldate', title: '操作日期',sort:false, sortname: 'filldate',minWidth: '120'}
                ,{field: 'attachmentUrl', title: '附件',sort:false, sortname: 'attachment_url',templet: function (d) {
                    if(d.attachmentUrl!=""){
                        var arrParse = JSON.parse(d.attachmentUrl);
                        return arrParse[0].fileName;
                    }else {
                        return d.attachmentUrl;
                    }
                }}
                ,showSta
                ,{field: 'remark', title: '备注',sort:false, sortname: 'remark'}
                ,{
                    fixed: 'right',
                    title: '管理',
                    toolbar: '#wQbdQualityAnalysisReportRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            },
            parseData: function(res){ //res 即为原始返回的数据
            common.parseDataList(res,['remark']);
            return {
                "code": res.code, //解析接口状态
                "msg": res.msg, //解析提示文本
                "count": res.count, //解析数据长度
                "data": res.data //解析数据列表
            };
        }
        });

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdQualityAnalysisReportTable',true);

        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
            //年选择器
            laydate.render({
                elem: '#start_time1'
                , type: 'year'
                , trigger: 'click'
            });
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdQualityAnalysisReportTable","wQbdQualityAnalysisReportQueryForm",{where:{}},isClear);
        }

        table.on('toolbar(wQbdQualityAnalysisReportTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdQualityAnalysisReport/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/exportData';
                            $("form[lay-filter='wQbdQualityAnalysisReportQueryForm']").find(".filter-value").each(function(i,value) {
                                if(i ==0){
                                    url += "?"+this.name+"="+this.value
                                }else{
                                    url += "&"+this.name+"="+this.value
                                }
                            });
                            window.location.href = url;
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/exportData?id=' + ids;
                            window.location.href = url;
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdQualityAnalysisReportTable',"/qbdms/wQbdQualityAnalysisReport/importData",false,"");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdQualityAnalysisReportTable');
                    dateReflash();
                    form.render();
                    break;
                case "send":
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    sendFun(data,array);
                    break;
            };
        });

        table.on('tool(wQbdQualityAnalysisReportTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/view/add?id='+data.id
                    break;
                case "particulars":
                    window.location.href = serverPath.qbdmsPath + '/qbdms/wQbdQualityAnalysisReport/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.alert(publicMethods.confirmStyle('请先选择一行数据!'),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdQualityAnalysisReport/del",
                        type: "post",
                        data: {id:id,datatype:1},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        //下发
        function sendFun(data,id){
            if (data.length === 0) {
                layer.alert(publicMethods.confirmStyle('请先选择一行数据!'),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定下发当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdQualityAnalysisReport/xf",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
            reflashQuery(false);
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdQualityAnalysisReportTable",{show:window.Initialization});
    });
</script>
</body>
</html>